<!-- 用户管理 Modal -->
<div class="modal fade" id="userMgmtModal" tabindex="-1" aria-labelledby="userMgmtLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="userMgmtLabel">用户管理</h5>
                <span id="userMgmtMsg" class="text-danger ms-3" style="display: none; font-size: 0.9rem;"></span>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="关闭"></button>
            </div>
            <div class="modal-body">
                <!-- 搜索栏 -->
                <div class="mb-3">
                    <input
                            id="userSearch"
                            type="text"
                            class="form-control"
                            placeholder="搜索用户名或真实姓名…"
                            autocomplete="off"
                    >
                </div>
                <table class="table table-hover" id="user-table">
                    <thead>
                    <tr>
                        <th>用户名</th>
                        <th>是否有效</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <!-- 由 user_mgmt.js 动态填充 -->
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button id="add-user-btn" type="button" class="btn btn-primary">添加用户</button>
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<!-- 添加用户 Modal -->
<div class="modal fade" id="addUserModal" tabindex="-1" aria-labelledby="addUserLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <form id="add-user-form" class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addUserLabel">添加用户</h5>
                <span id="addUserError" class="text-danger ms-3" style="display: none; font-size: 0.9rem;"></span>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="关闭"></button>
            </div>
            <div class="modal-body">
                <div class="mb-2">
                    <label class="form-label">用户名</label>
                    <input name="username" type="text" class="form-control" required>
                </div>
                <div class="mb-2">
                    <label class="form-label">姓名</label>
                    <input name="full_name" type="text" class="form-control">
                </div>
                <div class="mb-2">
                    <label class="form-label">密码</label>
                    <input name="password" type="password" class="form-control" required>
                </div>
                <div class="mb-2">
                    <label class="form-label">有效期</label>
                    <input name="expiry_date" type="date" class="form-control">
                </div>
                <div class="form-check mb-2">
                    <input name="is_admin" class="form-check-input" type="checkbox" id="add-is-admin">
                    <label class="form-check-label" for="add-is-admin">管理员权限</label>
                </div>
                <div class="mb-2">
                    <label class="form-label">备注</label>
                    <textarea name="remarks" class="form-control" rows="2"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">保存</button>
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
            </div>
        </form>
    </div>
</div>

<!-- —— 重置密码 Modal —— -->
<div class="modal fade" id="resetPwdModal" tabindex="-1" aria-labelledby="resetPwdLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm modal-dialog-centered">
        <form id="reset-pwd-form" class="modal-content reset-pwd-modal">
            <div class="modal-header">
                <h5 class="modal-title" id="resetPwdLabel">
                    <i class="bi bi-shield-lock-fill me-2"></i>重置密码
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="关闭"></button>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="new-password" class="form-label">新密码</label>
                    <input type="password" id="new-password" name="new_password" class="form-control" required>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary reset-pwd-btn">保存</button>
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
            </div>
        </form>
    </div>
</div>

<!-- —— 编辑用户 Modal —— -->
<div class="modal fade" id="editUserModal" tabindex="-1" aria-labelledby="editUserLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <form id="edit-user-form" class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="editUserLabel">编辑用户</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="关闭"></button>
            </div>
            <div class="modal-body">
                <div class="mb-2">
                    <label class="form-label">有效期</label>
                    <input name="expiry_date" type="date" class="form-control" required>
                </div>
                <div class="form-check mb-2">
                    <input name="is_admin" class="form-check-input" type="checkbox" id="edit-is-admin">
                    <label class="form-check-label" for="edit-is-admin">管理员权限</label>
                </div>
                <div class="mb-2">
                    <label class="form-label">备注</label>
                    <textarea name="remarks" class="form-control" rows="2"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">保存</button>
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
            </div>
        </form>
    </div>
</div>

<!-- 删除确认 Modal -->
<div class="modal fade" id="confirmDeleteModal" tabindex="-1" aria-labelledby="confirmDeleteLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="confirmDeleteLabel">确认删除</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="关闭"></button>
            </div>
            <div class="modal-body">
                是否删除该用户？删除后用户数据将清空。
            </div>
            <div class="modal-footer">
                <button id="delete-confirm-btn" type="button" class="btn btn-danger" disabled>
                    确认（5s）
                </button>
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
